home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / pascal / xlib.zip / XFILE.DOC < prev    next >
Text File  |  1992-09-06  |  4KB  |  145 lines

  1.  
  2.                                 XFile
  3.                                 -----
  4.  
  5. This unit give you object-oriented access to files.
  6.  
  7.  
  8. TFile
  9. ~~~~~
  10.  
  11. "TFile" implements a general object for file access. You can
  12. write your own descendants from this object for configuration-files,
  13. file-viewers, converters, etc.
  14.  
  15.  Fields:
  16.  -------
  17.  
  18.  FileName : PathStr      The name of the file should be accessed
  19.  F        : File         an untyped file variable
  20.  Buffer   : TextBuf      a placeholder for "TTextFile" object
  21.                          which use F as TEXT-file !
  22.  Status   : Integer      Here the status of the last operation is stored
  23.  
  24.  Methods
  25.  -------
  26.  constructor Init(AName:PathStr);
  27.   Initalize the object with AName. FileName is set to AName, Status
  28.   is cleared and F is assigned to FileName as untyped file.
  29.  
  30.  destructor  Done; virtual;
  31.   Close the file if opend and then shut down this object-instance
  32.  
  33.  function    Error(Code:Integer):boolean; virtual;
  34.   Any error occured on operations is reported to this method
  35.  
  36.  function    Open:Boolean; virtual;
  37.   Open the file with a record-size of 1
  38.  
  39.  function    Create:Boolean; virtual;
  40.   Create a file with a record-size of 1
  41.  
  42.  procedure   Close; virtual;
  43.   Close the file. But only if previous opend by an Open or
  44.   Create call !
  45.  
  46.  function    Exists:Boolean; virtual;
  47.   Determine if the file exists
  48.  
  49.  procedure   Delete; virtual;
  50.   Delete the file. Before deletion an open file might be closed.
  51.  
  52.  procedure   Seek ( Pos:Longint ); virtual;
  53.   Move the file-pointer to the specified position
  54.  
  55.  procedure   Write( var Buf; Count:Word ); virtual;
  56.   Write a data-block to the file
  57.  
  58.  procedure   Read ( var Buf; Count:Word ); virtual;
  59.   Read a data-block from the file
  60.  
  61.  function    ReplaceExt(NExt: ExtStr; Force:Boolean):PathStr; virtual;
  62.   Replace an existing Extentsion with another if no one exists
  63.   or Force is on TRUE
  64.  
  65.  procedure   Rename(NewName:PathStr); virtual;
  66.   Rename the file to
  67.  
  68.  procedure   Cut(At:Longint); virtual;
  69.   Cut the file at the specified position
  70.  
  71.  function    IsOpen:boolean; virtual;
  72.   Checks if the file is opend
  73.  
  74.  function    IsConsole:Boolean; virtual;
  75.   Checks if the file is a console device
  76.  
  77.  function    GetAttr:Word;          virtual;
  78.   Return the dos-attribut of the file
  79.  
  80.  procedure   SetAttr(NewAttr:Word); virtual;
  81.    Set an attribut to the file
  82.  
  83.  function    GetHandle:Word;        virtual;
  84.    Return the DOS-File Handle of the file
  85.  
  86.  function    GetDate:Longint;       virtual;
  87.    Return the file-date-time stamp
  88.  
  89.  function    GetLength:Longint;     virtual;
  90.    Return the current file-size
  91.  
  92.  function    GetDir:DirStr;         virtual;
  93.    Return only the directory part of the filepath
  94.  
  95.  function    GetName:NameStr;       virtual;
  96.    Return only the name part of the filepath
  97.  
  98.  function    GetExt:ExtStr;         virtual;
  99.    Return only the extentsion of the filepath. '.' included
  100.  
  101.  function    GetNameExt:PathStr;    virtual;
  102.    Return only the name and extentsion of the filepath, without
  103.    the directory
  104.  
  105.  function    GetDirName:PathStr;    virtual;
  106.    Return only the directory and name of the filepath, without
  107.    the extentsion
  108.  
  109.  function    GetPath:PathStr;       virtual;
  110.    Return the full filepath
  111.  
  112. TTextFile
  113. ~~~~~~~~~
  114. "TTextFile" is a decendant from "TFile" but access a Text-file.
  115. You can do Readln's and Writeln's to it.
  116.  
  117.  Fields:
  118.  -------
  119.  
  120.  FText    : ^Text        A pointer to a text-file
  121.  
  122.  Methods
  123.  -------
  124.  constructor Init(AName:PathStr);
  125.   Initalize the object with AName. FileName is set to AName, Status
  126.   is cleared and F is assigned to FileName as text file. Also
  127.   FText is set on F so that you can use text-file functions.
  128.   But note that you can't use furthermore functions like
  129.   Write/Read etc.
  130.  
  131.  function Open:boolean
  132.    Overwrite so that it opens a text-file
  133.  
  134.  function Create:boolean
  135.    Overwrite so that it create and open a text-file
  136.  
  137.  procedure Close;
  138.    Overwrite so that it close a text-file
  139.  
  140.  function  Eof:Boolean
  141.    Return TRUE if at the End-Of-File position in the
  142.    text file.
  143.  
  144.  
  145.